<?php
$db = new PDO('mysql:host=localhost; dbname=db3', 'root', '12qwas');
$ps=$db->prepare('select * from students limit :offset, :length');
$ps->bindParam(':offset',$offset,PDO::PARAM_INT);//此变量作为引用被绑定
$ps->bindParam(':length',$length,PDO::PARAM_INT);
$offset=$length=1;
$ps->execute();//只在 PDOStatement::execute()被调用的时候才取绑定变量的值。
foreach ($ps as $r){
    echo "{$r['xh']}\t{$r['name']}\t{$r['age']}\n";
}